import { store } from './index';

// 从store中推断出RootState和AppDispatch类型
export type RootState = ReturnType<typeof store.getState>;
export type AppDispatch = typeof store.dispatch;

// 用户信息类型
export interface UserInfo {
  id: string;
  username: string;
  email: string;
  phone?: string;
  avatar?: string;
  token: string;
  refreshToken?: string;
}

// 用户状态类型
export interface UserState {
  isLoggedIn: boolean;
  userInfo: UserInfo | null;
  loading: boolean;
  error: string | null;
}

// 用户列表项类型
export interface UserListItem {
  email: string;
  pwd: string;
  isAdmin: boolean;
}

// 用户列表状态类型
export interface UserListState {
  users: UserListItem[];
}

// 通用API响应类型
export interface ApiResponse<T = any> {
  code: number;
  message: string;
  data: T;
}

// 分页数据类型
export interface PaginationData<T> {
  list: T[];
  total: number;
  page: number;
  pageSize: number;
}

